public class Triangle extends ClosedFigure
{
    public Point point2, point3;
    protected double a, b, c;

    public Triangle(Point p1,Point p2,Point p3)
    {
        super("三角形",p1);
        if(new Line(p1,p2).contains(p3)) throw new IllegalArgumentException(p1+" , "+p2+" , "+p3+" at one line");
        this.point2=new Point(p2);
        this.point3=new Point(p3);
        this.a=new Line(p1,p2).length();
        this.b=new Line(p2,p3).length();
        this.c=new Line(p3,p1).length();
    }

    //    我也不清楚这个构造函数到底构造了些啥
//    public Triangle(Point p1,double a,double b,double c)
    public Triangle()
    {
        this(new Point(),new Point(),new Point());
    }

    public Triangle(Triangle tri)
    {
        this(tri.point1,tri.point2,tri.point3);
    }

//    public String toString()
//    {
//        return "Triangle{"+
//                "shape='"+shape+'\''+
//                ", point1="+point1+
//                ", point2="+point2+
//                ", point3="+point3+
//                ", a="+a+
//                ", b="+b+
//                ", c="+c+
//                '}';
//    }

    public String toString()
    {
        return "new Triangle("+point1+","+point2+","+point3+")";
    }

    public double perimeter()
    {
        return a+b+c;
    }

    public double area()
    {
        double s=(a+b+c)/2;
        return Math.sqrt(s*(s-a)*(s-b)*(s-c));
    }

    public Triangle revolve(double angle)
    {
        return revolve(point1,angle);
    }

    public Triangle revolve(Point p,double angle)
    {
        return new Triangle(this.point1.revolve(p,angle),this.point2.revolve(p,angle),this.point3.revolve(p,angle));
    }

    public Triangle zoom(double angle)
    {
        return zoom(point1,angle);
    }

    public Triangle zoom(Point p,double angle)
    {
        return new Triangle(this.point1.zoom(p,angle),this.point2.zoom(p,angle),this.point3.zoom(p,angle));
    }

    public boolean contains(Point p)
    {
        Point[] ps={point1,point2,point3};
        return new Polygon(ps).contains(p);
    }
}
